/**
 * Copyright (C) 2013 The yydorid-framework project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package net.yangying.androidframework.util;


/**
 * @author yangying
 *
 * @date 2012-7-18 下午3:03:16
 * 
 */
public class ChineseUtil {

	//  GENERAL_PUNCTUATION 判断中文的“号  
	  
    //  CJK_SYMBOLS_AND_PUNCTUATION 判断中文的。号  
  
    //  HALFWIDTH_AND_FULLWIDTH_FORMS 判断中文的，号  
  
    public static boolean isChinese(char c) {  
  
        Character.UnicodeBlock ub = Character.UnicodeBlock.of(c);  
  
        if (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS  
  
                || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS  
  
                || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A  
  
                || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION  
  
                || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION  
  
                || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS) {  
  
            return true;  
  
        }  
  
        return false;  
    }
    public static boolean existChinese(String strName) {
    	boolean flag=false;
        char[] ch = strName.toCharArray();
        for (int i = 0; i < ch.length; i++) {
            char c = ch[i];
            if (isChinese(c) == true) {
                flag=true;
                return flag;
            } else {
//                System.out.println(isChinese(c));
            }
        }
        return flag;
    }
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		System.out.println(ChineseUtil.existChinese("中国"));
		System.out.println(ChineseUtil.existChinese("abc.中国"));
		System.out.println(ChineseUtil.existChinese("abc.cn"));
		System.out.println(ChineseUtil.existChinese("哈哈.cn"));
	}

}
